//
//  MZMinViewController.swift
//  HiPlayer
//
//  Created by LB on 16/7/18.
//  Copyright © 2016年 TianChaoMinZu. All rights reserved.
//

import UIKit
import ChameleonFramework

class MZMinViewController: MZBaseTableViewController {
    
    let identifier : String = "SwiftCell"
    
    override func viewDidLoad() {
        super.viewDidLoad()

        setupUI()
        
        //自动隐藏导航栏
        self.navigationController!.navigationBarHidden = true
        
        // 注册一个可重用的Cell
        self.tableView!.registerClass(UITableViewCell.self,
                                      forCellReuseIdentifier: identifier)
    }
    
    // MARK: - TableViewDataSource & Deletage
    
    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 2
    }
    
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if section == 0 {
            return 1
        }else {
            return 10
        }
    }
    
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        //同一形式的单元格重复使用，在声明时已注册
        let cell = tableView.dequeueReusableCellWithIdentifier(identifier,
                                                               forIndexPath: indexPath) as UITableViewCell
        cell.accessoryType = .DisclosureIndicator
        cell.textLabel?.text = "HiPlayer"
        cell.textLabel?.textColor = FlatSkyBlueDark()
        
        cell.textLabel?.font = UI_FONT_16
        cell.detailTextLabel?.text = "这是一个很难阿萨德"
        cell.detailTextLabel?.textColor = FlatTealDark()
        cell.detailTextLabel?.font = UI_FONT_14
        
        return cell
    }
    
    override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        if indexPath.section == 0 {
            return 120.0
        }else {
            return 44.0
        }
    }
    
    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        tableView.deselectRowAtIndexPath(indexPath, animated: true)
        
        if indexPath.section == 0 {
            let playView = MZPlayerViewController()
            playView.hidesBottomBarWhenPushed = true
            self.navigationController?.pushViewController(playView, animated: true)
        }
    }
}

extension MZMinViewController {
    private func setupUI() {
        
    }
}